﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MetaEdit;

namespace IDE
{
	public partial class Options : Window
	{
		public Options()
		{
			InitializeComponent();
			this.Background = SystemColors.MenuBarBrush;
			//var test = Fonts.SystemFontFamilies.First();
			var fonts = Fonts.SystemFontFamilies.OrderBy(a => a.Source);
			font.ItemsSource = fonts;
			for (int i = 6; i < 25; i++)
			{
				fontSize.Items.Add(i);
			}
			font.Text = MetaEdit.Settings.Font;
			fontSize.Text = MetaEdit.Settings.FontSize;

			KeyDown += new KeyEventHandler(delegate (object sender, KeyEventArgs e)
			{
				if (e.Key == Key.Escape)
				{
					this.Close();
				}
			});
			ok.Click += delegate
			{
				MetaEdit.Settings.Font = font.Text;
				MetaEdit.Settings.FontSize = fontSize.Text;
				Editor.SaveSettings();
				foreach (MetaEdit.Editor.Page page in Editor.editor.tabs.Items)
				{
					page.textBox.FontFamily = Editor.font;
					page.textBox.FontSize = Editor.fontSize;
				}
				this.Close();
			};
			cancel.Click += delegate
			{
				this.Close();
			};
		}
	}
}